﻿namespace BM.Tools.WebControls.MForm.Example.Toolbox
{
    using System.Collections.ObjectModel;
    using System.Xml;
    using System.Xml.Serialization;
    using BM.Tools.WebControls.MForm.Generator;

    public class ToolBoxData
    {
        private Collection<SingleStyle> styles = new Collection<SingleStyle>();

        public string XPath
        {
            get; 
            set;
        }

        public ToolBoxActionType ActionType
        {
            get; 
            set;
        }

        public FormBuilderMode Mode
        {
            get; 
            set;
        }

        public bool Required
        {
            get; 
            set;
        }

        public bool Visible
        {
            get;
            set;
        }

        public Collection<SingleStyle> Styles
        {
            get
            {
                return styles;
            }
        }

        public static ToolBoxData Load(XmlDocument document)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(ToolBoxData));
            using(var reader = new XmlNodeReader(document))
            {
                return serializer.Deserialize(reader) as ToolBoxData;
            }            
        }
    }
}
